#include <iostream>
using namespace std;
// 错排
/* arr[1] = 0, arr[2] = 1;递推公式：arr[n] = (n-1)*(arr[n-1]+arr[n-1]); */
int main()
{
    long long arr[22] = {0, 0, 1};
    for(int i = 3; i < 21; ++i)
        arr[i] = (i-1) * (arr[i-1]+arr[i-2]);

    int n;
    while(cin >> n){
        cout << arr[n] << endl;
    }
    return 0;
}